//////////////////////////////////////////////////////////////////////////////////
//	 Copyright 2011 by Yosef Grabivker, ryuho@homenetworksoft.com
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//////////////////////////////////////////////////////////////////////////////////

//logdataprovider.h
#ifndef _LOG_DATA_PROVIDER_YG_H__
#define _LOG_DATA_PROVIDER_YG_H__

#include "def.h"
#include "guilogic.h"

struct CLogDataProvider
{
	

								CLogDataProvider(APPLOG& log):m_log(log) {}

	long						GetItemCount(wxWindowID id=wxID_ANY)
	{
		return m_log.size();
	}

	wxString					GetItemText(long item, long column, wxWindowID id=wxID_ANY)
	{
		wxString str;

		try
		{
			LOGENTRY& entry = m_log[item];

			switch(column)
			{
				case cColTypeTime:
				{
					wxDateTime dt(entry.tEvent);
					str = dt.Format( wxT("%c"));
				}
				break;

				case cColTypeEvtSrc:
				{
					if ( entry.strCustomEvent.IsEmpty() )
					{
						str = CGUILogic::PanelToName( entry.plType );
					}
					else
					{
						str = _("Application");
					}

					if ( entry.bStatus )
					{
						str = _("Status");
					}
				}
				break;

				case cColTypeEvtTxt:
				{
					if ( entry.strCustomEvent.IsEmpty() )
					{
						str = CGUILogic::StratToName( entry.strat );
					}
					else
					{
						str = entry.strCustomEvent;
					}
				}
				break;
			}


		}
		catch (...)
		{
		}

		return str;
	}

	int							GetItemColumnImage(long item, long column, wxWindowID id=wxID_ANY)
	{
		return -1;
	}

	virtual int					GetItemImage(long item, wxWindowID id=wxID_ANY)
	{
		return -1;
	}

	/*
	class wxListItemAttr*		GetItemAttr(long item, wxWindowID id=wxID_ANY)
	{
		return NULL;
	}*/

private:
	enum cColType { cColTypeTime=0, cColTypeEvtSrc, cColTypeEvtTxt };
	APPLOG& m_log;
};



#endif //_LOG_DATA_PROVIDER_YG_H__